#ifndef __P_CONFIG_H__
#define __P_CONFIG_H__

// sys
#define I2C_SCL_PIN 6
#define I2C_SDA_PIN 7

#define TICK_SYS 1 // ms
#define TICK_SENSOR_DATA_GET_MULTI 2000
#define TICK_SENSOR_DATA_SET_MULTI 1000

// u8g2
#define U8G2_WIDTH 128
#define U8G2_HEIGHT 64

#define U8G2_SLEEP_ENABLE
#define U8G2_SLEEP_TIME 30000 // ms

// u8g2 graph
#define U8G2_CHART_HEIGHT_DEFAULT 44
#define U8G2_CHART_ITEM_PIXEL_WIDTH_DEFAULT 1

// sensors
#define ES_ENABLE
// #define SENSOR_RAW_DATA_PRINT
// #define SENSOR_SGP30_SENSIRION_DRIVER
#define SENSOR_READ_AVG_NUM 3

// gas sensor
static const uint16_t EC02_MAX_VAL = 2000;
static const uint16_t EC02_MIN_VAL = 400;
static const uint16_t TVOC_MAX_VAL = 200;
static const uint16_t TVOC_MIN_VAL = 0;

static const float TEMP_MAX_VAL = 60.0f;
static const float TEMP_MIN_VAL = 0.0f;

// time
// NTP配置参数, 使用阿里云的NTP服务器
static const char *ntpServerUrl1 = "ntp1.aliyun.com";
static const char *ntpServerUrl2 = "ntp2.aliyun.com";
static const char *ntpServerUrl3 = "ntp3.aliyun.com";

#define KCE_PIN 45  // Chip Enable
#define KIO_PIN 48  // Input/Output
#define KSCK_PIN 47 // Serial Clock

// persistence
#define PERSISTENCE_KEY_MAX_NUM (6 * 24 * 1) // 每10分钟一次，1天。 144个数据动态滚动存储
// #define PERSISTENCE_KEY_MAX_NUM 1002 // only for test

#define FORMAT_LITTLEFS_IF_FAILED true
#define PERSISTENCE_MAX_FILES 30 // 保留30天
#define PERSISTENCE_DATA_FILE_DIR "/littlefs/paqm"
#define PERSISTENCE_PERIOD (60 * 10) // s

// add C:\Users\CharlesPu\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.12\tools\partitions\my_spiffs.csv
// # Name	   Type	 SubType	 Offset	  Size
// nvs	      data	 nvs	     0x9000	  0x5000
// otadata	  data	 ota	     0xe000	  0x2000
// app0	     app	  ota_0	   0x10000	 0x300000
// spiffs	   data	 spiffs	  0x310000	0x400000
// coredump	 data	 coredump	0x710000	0x10000
// then add to
// "C:\Users\CharlesPu\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.12\boards.txt"
// esp32s3.menu.PartitionScheme.my_spiffs=my_spiffs(large littlefs)
// esp32s3.menu.PartitionScheme.my_spiffs.build.partitions=my_spiffs

// wifi
#define WIFI_AP_MODE_SSID "PAQM"
#define WIFI_AP_MODE_PASSWORD "123654789"

// web server
#define WEB_SERVER_ASYNC // 启用异步webserver，非阻塞，更加高效
// #define WEB_SERVER_DEFAULT_ON // 是否默认开启，而不是外部按键触发

#define WEB_SERVER_PORT 80
#define WEB_SERVER_URL_DATA "/api/v1/data/get"
#define WEB_SERVER_URL_DATA_DOWNLOAD "/api/v1/data/download"
#define WEB_SERVER_URL_DATA_INFO "/api/v1/data/info"

#endif